//
//  NoNavViewController.m
//  BigJoy
//
//  Created by new-1020 on 2017/6/12.
//  Copyright © 2017年 Rowling. All rights reserved.
//

#import "NoNavViewController.h"
@interface NoNavViewController ()<UINavigationControllerDelegate>

@end

@implementation NoNavViewController

-(UIView *)cutomNavBarView {
    if (_cutomNavBarView == nil) {
        _cutomNavBarView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 64)];
        [_cutomNavBarView addSubview:self.serchView];
        [self.serchView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.top.bottom.equalTo(_cutomNavBarView);
        }];
        _cutomNavBarView.backgroundColor = navBacColor;
        [self.view addSubview:_cutomNavBarView];
    }
    return _cutomNavBarView;
}

-(HeaderSerchView *)serchView {
    if (_serchView == nil) {
        _serchView = [HeaderSerchView fastLogin];
    }
    return _serchView;
}

-(UIView *)BackClearView {
    if (_BackClearView == nil) {
        _BackClearView = [[UIView alloc]initWithFrame:CGRectMake(0, 20, SCREEN_WIDTH, 44)];
        
        UIView * realbackView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 64)];
        UIView * placHoldeView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 20)];
        [realbackView addSubview:placHoldeView];
        
        UIButton * backBtn = [XMSuperHelper XMbuttonWithFrame:CGRectMake(0, 0, 50, 50) Tile:@"" FontSize:17 selector:@selector(backBtnClick) Target:self];
        [backBtn setImage:[UIImage imageNamed:@"fanhuibaiyouyiny"] forState:UIControlStateNormal];
        backBtn.frame = CGRectMake(0, 0, 50, 50);
//        [backBtn sizeToFit];
        [self.view addSubview:realbackView];
        [realbackView addSubview:_BackClearView];
        [_BackClearView addSubview:backBtn];
        [backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(_BackClearView);
            make.left.equalTo(_BackClearView).offset(0);
            make.width.height.equalTo(@50);
        }];
        [backBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    }
    return _BackClearView;
}


- (void)viewDidLoad {
    [super viewDidLoad];
}

-(void)viewWillAppear:(BOOL)animated {
    self.navigationController.delegate = self;
}

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
    // 判断要显示的控制器是否是自己
    BOOL isShowHomePage = [viewController isKindOfClass:[self class]];
    
    [self.navigationController setNavigationBarHidden:isShowHomePage animated:YES];
}

-(void)backBtnClick {
    [self.navigationController popViewControllerAnimated:YES];
}


@end
